<?php
include_once 'protocol_includes.php';

class SoftwareUploaded extends subapplication
{
    private $cmd;
    public static $PROTOCOL = "SoftwareUploaded";

    public static function create(command $cmd)
    {
        if (!self::IsThisClass($cmd)) return null;
        $N = new SoftwareUploaded($cmd);
        return $N;
    }


    public function __construct(command $cmd)
    {
        $this->cmd  = $cmd;
        $this->LoginKey($cmd->GetData('LOGINKEY'));
        $this->SoftwareVersionID($cmd->GetData('SOFTWAREVERSIONID'));
        
    }

    public function  requiresAuthentication() {
        return true;
    }
    
    public function execute() 
    {
        ns_dao_software::MakeSoftwareVersionLive($this->SoftwareVersionID());
        $this->UpdateResult('NS_PROTOCOL=Debug&NS_DATA=SoftwareUploadRegistered');
    }


    // =========== PROPERTIES ==========

    private $property = array();
    private function GetSetData($property_name,$value = null)
    {
        if (is_null($value) && isset($this->property[$property_name])) return $this->property[$property_name];
        $this->property[$property_name] = $value;
    }

    public function LoginKey($value = null)
    {
        return $this->GetSetData("LOGINKEY",$value);
    }

    public function SoftwareVersionID($value = null)
    {
        return $this->GetSetData("SOFTWAREVERSIONID",$value);
    }

    public function result()
    {
        $this->cmd->GetResult();
    }

    public function UpdateResult($str)
    {
        $this->cmd->SetResult($str);
    }

    public static function IsThisClass(command $cmd)
    {

        if (!$cmd->HasDataKey('LOGINKEY')) return false;
        if (!$cmd->HasDataKey('SOFTWAREVERSIONID')) return false;


        return true;
    }
}

?>
